import Vue from 'vue'
import reshandler from 'services/response-handler'
import femal from "assets/femal.png";
import male from "assets/male.png";
import getLocation from 'services/get-location'

/*
 * 身边店信息 cityid 搜索关键字获取 搜索空显示全部
 * 
 */
function makeData(res) {
    console.log(res);
    let positionArr = [];
    let shopList = res.shops;
    let innerItem = {};
    let len = shopList.length;
    let distanceArr = [];
        for (let i = 0; i < len; i++) {
            let innerItem = {};
            //创建坐标数组用于进入地图页面
            innerItem.name = shopList[i].name;
            innerItem.latitude = shopList[i].latitude;
            innerItem.longitude = shopList[i].longitude;
            innerItem.route = false;
            positionArr.push(innerItem)
            let spec = ''
            for (let j = 0; j < shopList[i].specialServices.length; j++){
                if (j === shopList[i].specialServices.length - 1){
                    spec += shopList[i].specialServices[j]
                } else{
                    spec += shopList[i].specialServices[j] + '|'
                }
            }
            shopList[i].special = spec
        }
        return{
            shopList:shopList,
            positionArr: positionArr
        }
    }

export default function (params, success, fail) {
    this.$.get(params).then(reshandler.success(success, fail, makeData), reshandler.error(fail))
}
